<!DOCTYPE html>
<script src=../../resources/testharness.js></script>
<script src=../../resources/testharnessreport.js></script>
<script>
// This test verifies that captureStream() throws the right exceptions.

test(function() {
  var canvas = document.createElement('canvas');
  assert_throws_dom("NotSupportedError", function() { canvas.captureStream(-0.5) },
                    "cannot have negative frame rate");
}, 'check captureStream() throws Exception with invalid frame rate');

function makeAsyncTest() {
  return async_test(function(test) {
    var canvas = document.createElement('canvas');
    var ctx = canvas.getContext("2d");

    var image = document.createElement('img');
    image.onload = test.step_func(function() {
      var pattern = ctx.createPattern(image, 'repeat');
      ctx.fillStyle = pattern;
      ctx.fillRect(0, 0, 100, 100);

      assert_throws_dom("SecurityError", function() { canvas.captureStream() },
                        "cannot have cross origin");
      test.done();
    });
    image.src = "resources/svg-with-image-with-foreignobject.svg";
  }, 'check captureStream() throws Exception with cross origin content');
}

makeAsyncTest();

</script>
